/* $Id: ProcessStepActionDomainObjectManagerImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.domain.manager.provider;

import java.util.Collection;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import ae.pcfc.etks.online.common.ConstantsCommon.WorkflowDepartment;
import ae.pcfc.etks.online.common.dao.ProcessStepActionDAO;
import ae.pcfc.etks.online.common.domain.manager.ProcessStepActionDomainObjectManager;
import ae.pcfc.etks.online.common.exception.LookupException;
import ae.pcfc.etks.online.common.exception.PersistenceException;

public class ProcessStepActionDomainObjectManagerImpl implements ProcessStepActionDomainObjectManager{

	private ProcessStepActionDAO processStepActionDAO;
	
	/**
	 * setProcessStepActionDAO
	 * 
	 * @param processStepActionDAO
	 * void
	 */
	public void setProcessStepActionDAO(ProcessStepActionDAO processStepActionDAO) {
		this.processStepActionDAO = processStepActionDAO;
	}

	/**
	 * add
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#add(java.lang.Object)
	 * 
	 */
	public <T> void add(T obj) throws PersistenceException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * update
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#update(java.lang.Object)
	 * 
	 */
	public <T> void update(T obj) throws PersistenceException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * delete
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#delete(java.lang.Object)
	 * 
	 */
	public <T> void delete(T obj) throws PersistenceException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * findByPrimaryKey
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#findByPrimaryKey(java.lang.String)
	 * 
	 */
	public <T> T findByPrimaryKey(String id) throws LookupException {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * findAll
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#findAll()
	 * 
	 */
	public <T> Collection<T> findAll() throws LookupException {
		// TODO Auto-generated method stub
		return null;
	}
	/**
	 * isAllDepartmentsApproved
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ProcessStepActionDomainObjectManager#isAllDepartmentsApproved(java.util.List, java.lang.String)
	 * 
	 */
	public boolean isAllDepartmentsApproved(List<WorkflowDepartment> departments, String applicationId){
		if(departments != null && applicationId != null && !StringUtils.isBlank(applicationId)){
			for(WorkflowDepartment dept : departments){
				if(dept != null && !this.processStepActionDAO.isApplicationApprovedByDepartment(dept.getCode(), applicationId)){
					return false;
				}
			}
			return true;
		}
		return false;
	}

	/**
	 * isAllDepartmentsActed
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ProcessStepActionDomainObjectManager#isAllDepartmentsActed(java.util.List, java.lang.String)
	 * 
	 */
	public boolean isAllDepartmentsActed(List<WorkflowDepartment> departments, String applicationId) {
		if(departments != null && applicationId != null && !StringUtils.isBlank(applicationId)){
			for(WorkflowDepartment dept : departments){
				if(dept != null && !this.processStepActionDAO.isApplicationActedByDepartment(dept.getCode(), applicationId)){
					return false;
				}
			}
			return true;
		}
		return false;
	}
}
